/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package hibernatemodelo;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Z510
 */
@Entity
@Table(name = "seramigo")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Seramigo.findAll", query = "SELECT s FROM Seramigo s"),
    @NamedQuery(name = "Seramigo.findById", query = "SELECT s FROM Seramigo s WHERE s.id = :id"),
    @NamedQuery(name = "Seramigo.findFriends", query = "SElect s from Seramigo s WHERE s.idamigo1 = :id or s.idamigo2 = :id")})
public class Seramigo implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @JoinColumn(name = "idamigo2", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Contacto idamigo2;
    @JoinColumn(name = "idamigo1", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Contacto idamigo1;

    public Seramigo() {
    }

    public Seramigo(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Contacto getIdamigo2() {
        return idamigo2;
    }

    public void setIdamigo2(Contacto idamigo2) {
        this.idamigo2 = idamigo2;
    }

    public Contacto getIdamigo1() {
        return idamigo1;
    }

    public void setIdamigo1(Contacto idamigo1) {
        this.idamigo1 = idamigo1;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Seramigo)) {
            return false;
        }
        Seramigo other = (Seramigo) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "hibernatemodelo.Seramigo[ id=" + id + " ]";
    }
    
}
